<?php
namespace Home\Controller;
use Think\Controller;
            
class IndexController extends Controller {
    
    public function index($cid="0",$px="sell",$page="1"){
        if($page<=0){
            $page=1;
            //echo "无敌美少女在此";
        }
        //echo $cid;
        $new=new \Org\getlist;
        $json=$new->ajaxCat($cid,$page,$px);
        $json1=json_decode($json,true);
        $this->assign("px",$px);
        $this->assign("cid",$cid);
        $this->assign("page",$page);
        //var_dump($json1['data']);
        if(count($json1['data'])==0){
            $this->display("no_more.html");
        }else{
            $this->assign("json",$json1['data']);
            $this->display();
        }
    }
    
    public function cat($cid="0",$px="sell",$page="1"){
        if($page<=0){
            $page=1;
            //echo "无敌美少女在此";
        }
        //echo $cid;
        $new=new \Org\getlist;
        $json=$new->ajaxCat($cid,$page,$px);
        $json1=json_decode($json,true);
        $this->assign("px",$px);
        $this->assign("cid",$cid);
        $this->assign("page",$page);
        //var_dump($json1['data']);
        if(count($json1['data'])==0){
            $this->display("no_more.html");
        }else{
            $this->assign("json",$json1['data']);
            $this->display();
        }
        
        //var_dump($json1['data']);
        
        

    }
        public function nine($page="1"){
        if($page<=0){
            $page=1;
            //echo "无敌美少女在此";
    
        }
        //echo $cid;
        $new=new \Org\getlist;
        $json=$new->ajaxNine($page);
        $json1=json_decode($json,true);
        //var_dump($json1['data']);
        if(count($json1['data'])==0){
            $this->display("no_more.html");
        }else{
            $this->assign("json",$json1['data']);
             $this->assign("page",$page);
            $this->display();
        }
        
        //var_dump($json1['data']);
        
        

    }
        public function R($page="0"){
        if($page<=0){
            $page=1;
            //echo "无敌美少女在此";
        }
        //echo $cid;
        $new=new \Org\getlist;
        $json=$new->ajaxR($page);
        $json1=json_decode($json,true);
        $this->assign("page",$page);
        //var_dump($json1['data']);
        if(count($json1['data'])==0){
            $this->display("no_more.html");
        }else{
            $this->assign("json",$json1['data']);
            $this->display();
        }
        
        //var_dump($json1['data']);
        
        

    }
        public function S($kw="",$page="0",$px="t"){
        if($page<=0){
            $page=1;
            //echo "无敌美少女在此";
        }
        //echo $cid;
        $new=new \Org\getlist;
        $json=$new->ajaxSearch($kw,$page,$px);
        $json1=json_decode($json,true);
        $this->assign("px",$px);
        $this->assign("kw",$kw);
        $this->assign("page",$page);
        //var_dump($json1['data']);
        if(count($json1['data'])==0){
            $this->display("no_more.html");
        }else{
            $this->assign("json",$json1['data']);
            $this->display();
        }
        
        //var_dump($json1['data']);
        
        

    }
    public function read($id=""){
        if($id==""){
            $this->error('没有内容','/Good',3);
        }
        $new=new \Org\getread;
        $json=$new->read($id);
        
        if ($json==NULL){
            $this->error('没有内容','/Good',3);
        }else{
        $json1=json_decode($json,true);
        $this->assign("title",$json1['title']);
        $this->assign("tuijian",$json1['tuijian']);
        $this->assign("qprice",$json1['qprice']);
        $this->assign("img",$json1['img']);
        $this->assign("now_price",$json1['now_price']);
        $this->assign("old_price",$json1['old_price']);
        $this->assign("sell",$json1['sell']);
        $this->assign("quan",$json1['quan']);
        $this->assign("goodid",$json1['goodid']);
        $this->display();
        //var_dump($json1);
        }
        
    }
    
    public function jsoncat($r="",$cid="0",$px="sell",$page="1",$kw=""){
        header("Content-type:application/json");
        $get=new \Org\getlist;
        if($r=="s"){
            $json=$get->ajaxSearch($kw,$page,$px);
        }elseif($r=="l"){
            $json=$get->ajaxCat($cid,$page,$px);
        }elseif($r=="n"){
            $json=$get->ajaxNine($page);
        }elseif($r=="r"){
            $json=$get->ajaxR($page);
        }
        echo $json;
    }
    
    public function kouling($md5,$title="",$pic="",$url=""){
       if($md5=md5(time())){
        $test=new \Org\Tao\test;
        $json=$test->kouling($title,$pic,$url);
        echo $json;
       }else{
           echo "false";
       }
    }
    
    public function test(){
        $get=new \Org\getlist;
        $json=$get->ajaxNine(0);
        $json1=json_decode($json,true);
        shuffle($json1['data']);
        echo json_encode(array_slice($json1['data'],0,5,true));
    }

}